package com.caterina.components;
import com.caterina.activityManager.CActivity;

public abstract class CActivityButton extends CButton{
	public CActivityButton(String text,CActivity thisActivity){
		this(text,thisActivity,false);
	}
	public CActivityButton(String text,CActivity thisActivity,boolean asLink){
		super(text,asLink);
		this.thisActivity=thisActivity;
		this.setNextActivity(thisActivity);
	}
	public void inibite(){
		this.hasInibite=true;
	}

	public void setNextActivity(CActivity nextActivity){
		this.nextActivity=nextActivity;
	}
	public void toNextActivity(){
		this.thisActivity.getActivityManager().switchActivity(nextActivity);
	}
	public void onAction(){	
		this.onClick();
		if(!hasInibite)this.toNextActivity();
		else this.hasInibite=false;
	}
	public void onFocus() {}
	
	public Object getContent(){
		return this.nextActivity;
	}

	private boolean hasInibite=false;
	protected abstract void onClick();

	protected CActivity thisActivity;

	protected CActivity nextActivity;
	private static final long serialVersionUID = 1L;
}